﻿//  -------------------- iSharePoint -------------------- //
// 
//  Company:	IT Complex, LLC
//  Project:	Smart.Common
//  File name:	IRouterService.cs
//  Developer:	Solomatov Igor
//  Created:	15.04.2012
// 
//  -------------------- iSharePoint -------------------- //

namespace Smart.Common.Router
{
	/// <summary>
	/// Router service
	/// </summary>
	public interface IRouterService
	{
		/// <summary>
		/// Router context
		/// </summary>
		RouterContext Ctx { get; set; }

		/// <summary>
		/// Current router source (lazy)
		/// </summary>
		RouterSource Source { get; set; }

		/// <summary>
		/// Create router source
		/// </summary>
		RouterSource CreateSource();

		/// <summary>
		/// Create router source
		/// </summary>
		RouterFormatter CreateFormatter();

		/// <summary>
		/// Init service (also fills lazy properties)
		/// </summary>
		void InitService();

		/// <summary>
		/// Init router context
		/// </summary>
		void InitContext(string serviceName);

		/// <summary>
		/// Ensure that uri exists
		/// </summary>
		bool EnsureUriExists(string uri);

		/// <summary>
		/// Get formatted uri by name. Ensure that uri corresponds to the real path.
		/// </summary>
		string GetUri(string name, params object[] values);

		/// <summary>
		/// Get formatted uri and template type by name. Ensure that uri corresponds to the real path.
		/// </summary>
		string GetUri(string name, out string type, params object[] values);

		/// <summary>
		/// Get object by name and values
		/// </summary>
		object Get(string name, params object[] values);

		/// <summary>
		/// Get templated object by name and values
		/// </summary>
		TObjectType Get<TObjectType>(string name, params object[] values)
			where TObjectType : class;

		/// <summary>
		/// Add or update router template
		/// </summary>
		bool AddOrUpdateTemplate(RouterTemplate template);
	}
}